//
//  UIStepperDemo.swift
//  firstProject
//
//  Created by 张彦辉 on 2017/4/4.
//  Copyright © 2017年 张彦辉. All rights reserved.
//

import UIKit

class UIStepperDemo: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.gray
        //步径控制器
        let stepper:UIStepper = UIStepper(frame: CGRect(x: 100, y: 300, width: 100, height: 100))
        //添加方法
        stepper.addTarget(self, action: #selector(valueChange), for: .valueChanged)
        //设置步长
        stepper.stepValue = 2
        //设置最大值
        stepper.maximumValue = 10
        //设置最小值
        stepper.minimumValue = 2
        //是否连续触发响应函数
        stepper.isContinuous = false
        //值是否持续改变
        stepper.autorepeat = false
        //设置值是否循环
        stepper.wraps = true
        //设置颜色
        stepper.tintColor = UIColor.red

        self.view.addSubview(stepper)
    }
    
    func valueChange(stepper:UIStepper) -> Void {
        print(stepper.value)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
